package com.rykj.energy.task.manage.actuator.impl;

import com.rykj.energy.common.dto.TaskCameraRelationDto;
import com.rykj.energy.task.manage.actuator.ITaskManage;
import com.rykj.energy.task.manage.schedule.IQuartzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CaptureTaskManage implements ITaskManage {

    @Autowired
    private IQuartzService quartzService;

    @Override
    public boolean startTask(List<TaskCameraRelationDto> voList) throws Exception {

//        for(TaskCameraRelationDto relationDto : voList){

            //解析执行计划
//            quartzService.addJobSeconds(ManualCaptureJob.class);
//        }
        return true;
    }

    @Override
    public boolean stopTask(List<TaskCameraRelationDto> voList) throws Exception {

        for(TaskCameraRelationDto relationDto : voList){
            String jName = relationDto.getCameraId() + "-" + relationDto.getPresetId()==null?"0":relationDto.getPresetId() + "-" + relationDto.getTaskCode();
            String jGroup = relationDto.getTaskType();
            //停止执行计划
            quartzService.deleteJob(jName,jGroup);
        }
        return true;
    }

    @Override
    public boolean updateTask(List<TaskCameraRelationDto> voList) throws Exception {

        return true;
    }

}
